package net.taviscaron.drivenotes.android.service;

import net.taviscaron.drivenotes.android.Constants;
import net.taviscaron.drivenotes.com.google.gson.Gson;
import net.taviscaron.drivenotes.com.google.gson.GsonBuilder;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;

public class BaseService {
    protected Context context;
    protected Gson gson;
    
    public BaseService(Context context) {
	this.context = context;

	gson = new GsonBuilder().create();
    }
    
    public boolean isOnline() {
	 ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
	 return cm.getActiveNetworkInfo().isConnectedOrConnecting();
    }
    
    protected String token() {
	SharedPreferences preferenceManager = PreferenceManager.getDefaultSharedPreferences(context);
	return preferenceManager.getString(Constants.AUTH_KEY_PROP_KEY, null);
    }
}
